var httpment1=null;
var httpment2=null;
var alarmCount=0;
var monitorFlag=true;
// 页面加载之后调用此方法，实时获取园内数据
var refreshTime=10;
var allReaderData;
var readerDataMap;
var updateReaderTimer = 0;

function _cancelReadersUpdate()
{
	window.clearTimeout(updateReaderTimer);
}

function _doReadersUpdate(result)
{
	allReaderData = eval("("+result+")");
	
	for (var j = 0; j < allReaderData.length; j++) {
		for(var i = 0; i < allReaderData[j].listRead.length; i++) {
			
			// 修改读头人数
			modifyReader(allReaderData[j].listRead[i].lrmID, allReaderData[j].listRead[i].empCountIn,allReaderData[j].listRead[i].empAQ,allReaderData[j].listRead[i].empXMZY,allReaderData[j].listRead[i].empWL,allReaderData[j].listRead[i].empXMGL,allReaderData[j].listRead[i].empJL,allReaderData[j].listRead[i].QC, allReaderData[j].listRead[i].empCountOut, allReaderData[j].listRead[i].lrmState);
		}
		for(var i = 0; i < allReaderData[j].listArea.length; i++) {
			// 修改区域人数
			modifyArea(allReaderData[j].listArea[i].id, allReaderData[j].listArea[i].relEmpCount);			
		}
		// 获取园内总人数
		getId(countAll).innerHTML="";
		getId(countAll).innerHTML = "工地内人数：<a href='javascript:void(0)' onclick='openEmpData(\"/SCMDB/monitorDataAction!findAll.action?searchType=1&department=0&workType=0\")'>" + allReaderData[j].countAll + "</a>";
		
		// showTime();
		// 清除shiftsDiv
		if (getId("shiftsEmp")) {
			getId("shiftsEmp").innerHTML = "";
		}
		for (var i = 0; i < allReaderData[j].shiftsEmp.length; i++) {
			showShifts(allReaderData[j].shiftsEmp[i].id, allReaderData[j].shiftsEmp[i].name, allReaderData[j].shiftsEmp[i].countEmp);
		}
	}
	
	if(getId("loading").style.display=="block"){
		getId("loading").style.display="none";
	}
	
	_updateReaderTimer=window.setTimeout("_updateDataFlow("+refreshTime+")",refreshTime * 1000);
}

function _updateDataFlow(refresh)
{
	refreshTime = refresh;
	
	var now = new Date().getTime();
	// 参数：部门、工种
	var parameter = {
			"department" :0,
			"workType" : 0
	}
	var url="/SCMDB/monitorAction!monitorShow.action?r="+now;
	// 提交请求
	jQuery.post(url, parameter, _doReadersUpdate);

}

function _fetchProgress()
{
	//here to fetch tunnel build progress info;
	url = "/SCMDB/monitorAction!getProcessInfo.action";// fix his later;
	//jQuery.post(url, {}, buildProgressCallback);
	
	$.ajax({
	type:"POST",
	async:false,
	url: url,
	success:buildProgressCallback,
	timeout: 10000,
	error:buildProgressFailureCallback,
	});
}

function _fetchReaderStatusFlow(){
	//refreshTime=refresh;
	var now = new Date().getTime();
	// 参数：部门、工种
	var parameter = {
			"department" :0,
			"workType" : 0
	}
	var url="/SCMDB/monitorAction!monitorShow.action?r="+now;
	// 提交请求
	jQuery.post(url, parameter, readerDataCallback);
}

function _getAllReaderData()
{
	return allReaderData;
}

function _getReaderMap()
{
	return readerDataMap;
}

function _updateReaderStatus()
{
		for (var j = 0; j < data.length; j++) {
				for(var i = 0; i < data[j].listRead.length; i++) {
					
					// 修改读头人数
					modifyReader(data[j].listRead[i].lrmID, data[j].listRead[i].empCountIn,data[j].listRead[i].empAQ,data[j].listRead[i].empXMZY,data[j].listRead[i].empWL,data[j].listRead[i].empXMGL,data[j].listRead[i].empJL,data[j].listRead[i].QC, data[j].listRead[i].empCountOut, data[j].listRead[i].lrmState);
				}
				for(var i = 0; i < data[j].listArea.length; i++) {
					// 修改区域人数
					modifyArea(data[j].listArea[i].id, data[j].listArea[i].relEmpCount);			
				}
				// 获取园内总人数
				getId(countAll).innerHTML="";
				getId(countAll).innerHTML = "工地内人数：<a href='javascript:void(0)' onclick='openEmpData(\"/SCMDB/monitorDataAction!findAll.action?searchType=1&department=0&workType=0\")'>" + data[j].countAll + "</a>";
				
				// showTime();
				// 清除shiftsDiv
				if (getId("shiftsEmp")) {
					getId("shiftsEmp").innerHTML = "";
				}
//				for (var i = 0; i < data[j].shiftsEmp.length; i++) {
//					showShifts(data[j].shiftsEmp[i].id, data[j].shiftsEmp[i].name, data[j].shiftsEmp[i].countEmp);
//				}
			}
			if(getId("loading").style.display=="block"){
				getId("loading").style.display="none";
			}
			httpment1=window.setTimeout("displayMonitor("+refreshTime+")",refreshTime * 1000);
}

function buildProgressFailureCallback()
{
	var all_id = ["progSvg0", "progSvg1", "progSvg2", "progSvg3"];
	
	for (var i = 0 ; i < all_id.length; i ++)
	{
		var svgID = all_id[i];
		progList[svgID]["curRingNo"] = 0;
		progList[svgID]["lastRingRecord"] = 0;
		progList[svgID]["unreportedRings"] = [];
	}
}

function buildProgressCallback(result)
{
	//bind value to prog0, prog1, prog2, prog3
	var proc_info = eval("(" + result + ")");
	var valid_info = proc_info[0];
	var map = new Array();
	
	
	for(var key in valid_info)
	{
		if(typeof( valid_info[key] ) != "object")
			continue;
		
		var sectionNo = key;
		var sectionInfo = valid_info[sectionNo];
		
		var svgID = _sectionNo2SvgID(sectionNo);
		
		if(sectionInfo.length == 0)
		{
			progList[svgID]["curRingNo"] = 0;
			progList[svgID]["lastRingRecord"] = 0;
			progList[svgID]["unreportedRings"] = [];
			continue;
		}
		
		var curRingNo = sectionInfo[0];
		var lastRingRecord = sectionInfo[1];
		var unreportedRings = sectionInfo[3];
		
		
	
		progList[svgID]["curRingNo"] = curRingNo;
		progList[svgID]["lastRingRecord"] = lastRingRecord;
		progList[svgID]["unreportedRings"] = unreportedRings;

	}
	
	
	_setAllProg();
}

function readerMapCallback(result)
{
	readerDataMap = eval("(" + result + ")");
	
	_drawPerMapReader();
}

function readerDataCallback(result){
		allReaderData = eval("("+result+")");
		
		var url="/SCMDB/monitorAction!getReaderMap.action";
		jQuery.post(url, {}, readerMapCallback);
}

// 打开报警面板的时候调用此方法，实时获取报警信息
function displayAlarm(refresh){
	refreshTime=refresh;
	var now = new Date().getTime();

	// 参数：部门、工种
	var parameter = {
			"department" : 0
	}
	var url="/SCMDB/monitorAlarmAction!monitorShow.action?department=0&r=" + now;
	// 提交请求
	jQuery.post(url, parameter, alarmCallback);
}

function alarmCallback(result) {
	var data = eval("("+result+")");
	var alarmFlag=false;
	if(data){
		for (var j = 0; j < data.length; j++) {
			getId("alarmText"+data[j].id).innerText=data[j].alarmCount;
			if(data[j].alarmCount>0){
				getId("alarmState"+data[j].id).src="/SCMDB/images/red.jpg";
				alarmFlag=true;
			}else{
				getId("alarmState"+data[j].id).src="/SCMDB/images/green.jpg";
			}
		}
		if(alarmFlag){
			if(getId("alarmOperator").checked){
				if(getId("alarmSound").movie=="/SCMDB/images/cancelAlarm.swf"){
					getId("alarmSound").movie="/SCMDB/images/alarm_01.swf";
				}
			}
		}else{
			getId("alarmSound").movie="/SCMDB/images/cancelAlarm.swf";
		}
	}
	httpment2=window.setTimeout("displayAlarm("+refreshTime+")", refreshTime * 1000);
}
function cancleAlarm(){
	if(!getId("alarmOperator").checked){
		getId("alarmSound").movie="/SCMDB/images/cancelAlarm.swf";
	}
}
// 修改读头人数
function modifyReader(lrmID, empCountIn,empAQ,empJL,empWL,empXMZY,empXMGL,QC, empCountOut, lrmState){
	var reader = getId("read"+lrmID);
	var inSpan= getId("inSpan"+lrmID);
	var outSpan= getId("outSpan"+lrmID);
	if (1 == lrmState) {
		reader.style.background = "url(/SCMDB/images/reader-1.gif) no-repeat";
	} else {
		reader.style.background = "url(/SCMDB/images/reader_bd-1.gif) no-repeat";
	}
	var str = "";
	//if (empCountIn > 0) {		
		// 如果读头存在并且人数大于0
		//inSpan.innerText=empCountIn;
		inSpan.innerHTML="<table class=\"mpatable\" <tr><td colspan=\"4\"><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3\")\' class=\"maplink7\">总："+empCountIn+"</a></td></tr> <tr>   <td><img src=\"/SCMDB/images/blueicon.gif\" width=\"12\" height=\"12\" /></td>  <td><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3&empType=4\")\' class=\"maplink1\">"+empAQ+"</a></td>  <td><img src=\"/SCMDB/images/greenicon.gif\" width=\"12\" height=\"12\" /></td>  <td><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3&empType=2\")\' class=\"maplink2\">"+empJL+"</a></td> </tr> <tr>   <td><img src=\"/SCMDB/images/redicon.gif\" width=\"12\" height=\"12\" /></td>  <td><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3&empType=5\")\' class=\"maplink3\">"+empWL+"</a></td>  <td><img src=\"/SCMDB/images/yelicons.gif\" width=\"12\" height=\"12\" /></td>  <td><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3&empType=1\")\' class=\"maplink4\">"+empXMZY+"</a></td> </tr>  <tr>  <td><img src=\"/SCMDB/images/blaicon.gif\" width=\"12\" height=\"12\" /></td>  <td><a href=\"#\" onclick=\'openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3&empType=3\")\' class=\"maplink5\">"+empXMGL+"</a></td>  <td ><img src=\"/SCMDB/images/tractor.gif\" width=\"12\" height=\"12\" /></td><td>"+QC+"</td> </tr></table>";
	//	inSpan.onclick=new Function("openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=3\")");
	/*	if (empCountOut > 0) {
			outSpan.innerText="|"+empCountOut;
			outSpan.onclick=new Function("openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=5\")");
		}else{
			outSpan.innerText="";
		}*/
/*	} else {
		inSpan.innerText="";
		if (empCountOut > 0) {
			outSpan.innerText="0|"+empCountOut;	
			outSpan.onclick=new Function("openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idReader="+lrmID+"&searchType=5\")");
		}else{
			outSpan.innerText="";
		}
	}*/
}

// 修改读头人数
function modifyArea(areaID, empCount){
	var area = getId("area"+areaID);
	var areaSpan=getId("inAreaSpan"+areaID);
	if (area) {
		if (empCount > 0) {
			// 如果读头存在并且人数大于0
			areaSpan.innerText =empCount;
			areaSpan.onclick=new Function("openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idArea="+areaID+"&searchType=4\")");
		}else{
			areaSpan.innerText="";
		}
	}
}
// 修改班次人数
function showShifts(idShift, nameShift, countEmp){
	var shift = getId("shiftsEmp");
	var str = shift.innerHTML;
	if (str == undefined) {
		str = "";
	}
	str += nameShift + "：<a href='javascript:void(0)' onclick='openEmpData(\"/SCMDB/monitorDataAction!findAll.action?idShift="+idShift+"&searchType=2&department=0&workType=0\")'>" + countEmp + "</a> ";
	shift.innerHTML = str;
}
// 打开人员详细信息页面
function openEmpData(url){
	window.open(url);
}
// 打开报警详细信息页面
function displayAlarmInfor(id){
	Super.Popup(5,"查询","/SCMDB/monitorAlarmAction!findAlarmByType.action?idAlarmType="+id,"",900,460);
}
// 处理实时监控的卡片定位
function AjaxTagSearch(tagSearchValue,type) {
	var txt = getId(tagSearchValue).value;
	var now = new Date().getTime();
	var parameter = {
			"tag" : txt
	}
	if(txt.length=="0"){
		return false;
	} else{
		// 清除之前查询记录。
		if(getId("searchDetail")){
			getId("mainDiv").removeChild(getId("searchDetail"));
			getId("mainDiv").removeChild(getId("sdClose"));	
		}
		var url = "/SCMDB/monitorEmpPositionAction!searchByTag.action?time=" + Math.round(Math.random());
		// 提交请求
		jQuery.post(url, parameter, tagSearchCallback);
	}
}

function tagSearchCallback(result) {
	var data = eval("("+result+")");
	if (data.length == 0) {
		tagPositionBuild("99","0","0","1");
	} else {
		for (var i=0; i<data.length; i++){						
			// 调用tagPositionBuild函数
			tagPositionBuild("0", data[i].empName, data[i].empLabelID, data[i].XPos, data[i].YPos, data.length, data[i].empDep);
		}	
	}
}

// 卡片定位
function tagPositionBuild(type,tagName,tagId,tagX,tagY,tagLength, empDep){
	// 人员定位
	var mapDiv=getId("mainDiv");
	// alert(type+":--:"+tagName+":--:"+tagId+":--:"+tagX+":--:"+tagY+":--:"+tagLength);
	if(!getId("searchDetail")){
		var sDetail = document.createElement("div");			
		sDetail.setAttribute("id","searchDetail");
		sDetail.style.position = "absolute";
		sDetail.style.border = "1px solid #ccc";
		sDetail.style.top="0px";
		sDetail.style.left="0px";
		sDetail.style.background="#fff";		
		sDetail.style.width="180px";
		sDetail.style.height="150px";
		sDetail.style.zIndex = "9999";
		mapDiv.appendChild(sDetail);

		if(!getId("sdClose")){
			var sdClose = document.createElement("div");			
			sdClose.setAttribute("id","sdClose");
			sdClose.style.position = "absolute";
			sdClose.style.top="149px";
			sdClose.style.left="0px";
			sdClose.style.background="#fff";		
			sdClose.style.width="180px";
			sdClose.style.height="22px";		
			sdClose.style.textAlign="center";
			sdClose.style.border="1px solid #ccc";
			sdClose.style.zIndex = "9999";
			mapDiv.appendChild(sdClose);		
			sdClose.innerHTML="<input type=\"button\" name=\"bcloseDetail\" value=\"关闭\" style=\"border:1px solid #ccc;margin:1px; height:18px; width:40px;cursor:pointer;\" onclick=\"bSearchDetailClode();\" />";
			// alert(getId("sdClose").innerHTML);
		}

		if(type=="99"){
			sDetail.innerHTML="<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showSearchTab\" id=\"sTable\"><tr><th width=\"85\">卡号</th><th width=\"85\">名称</th><th>类别</th><th>X</th><th>Y</th></tr><tr><td colspan=\"5\">查询不到相关数据!</td></tr></table>"
		} else {
			sDetail.innerHTML="<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showSearchTab\" id=\"sTable\"><tr><th width=\"85\">卡号</th><th width=\"85\">名称</th><th>类别</th><th>X</th><th>Y</th></tr></table>"
				

			// 添加行
			var signFrame=getId("sTable");
			var newTR = signFrame.insertRow(signFrame.rows.length);
			newTR.id = "SignItem" + tagId;
			
			var newIdTD=newTR.insertCell(0);
			newIdTD.innerHTML = tagId;
			
			var newNameTD=newTR.insertCell(1);
			newNameTD.innerHTML = tagName;
			
			var newTypeTD=newTR.insertCell(2);
			newTypeTD.innerHTML = type;
			
			var newTagXTD=newTR.insertCell(3);
			newTagXTD.innerHTML = tagX;

			var newTagYTD=newTR.insertCell(4);
			newTagYTD.innerHTML = tagY;

			newTR.onmouseover=function(){
				this.style.fontWeight="bold";
			}
			newTR.onmouseout=function(){
				this.style.fontWeight="normal";
			}
			newTR.onclick=function(){
				moveFlag=true;
				showInfoFlag=true;
				var tableTrs=signFrame.getElementsByTagName("tr");
				for(var i=0;i<tableTrs.length;i++){	
					tableTrs[i].className="";
				}
				
				this.className="clickTr";
				var clickTds=this.getElementsByTagName("td");
				showInfoArray=[clickTds[0].innerHTML,clickTds[1].innerHTML,clickTds[2].innerHTML,,clickTds[3].innerHTML,clickTds[4].innerHTML];			
				tagSetPostion(clickTds[0].innerHTML,clickTds[1].innerHTML,clickTds[2].innerHTML,"",clickTds[3].innerHTML,clickTds[4].innerHTML, empDep);
			}
		}
	}else{
		// 添加行

		var signFrame=getId("sTable");
		
		var newTR = signFrame.insertRow(signFrame.rows.length);
		newTR.id = "SignItem" + tagId;
		
		var newIdTD=newTR.insertCell(0);
		newIdTD.innerHTML = tagId;
	
		var newNameTD=newTR.insertCell(1);
		newNameTD.innerHTML = tagName;
		
		var newTypeTD=newTR.insertCell(2);
		newTypeTD.innerHTML = type;
		
		var newTagXTD=newTR.insertCell(3);
		newTagXTD.innerHTML = tagX;
		
		var newTagYTD=newTR.insertCell(4);
		newTagYTD.innerHTML = tagY;

		newTR.onmouseover=function(){
			this.style.fontWeight="bold";
		}
		newTR.onmouseout=function(){
			this.style.fontWeight="normal";
		}
		newTR.onclick=function(){
			moveFlag=true;
			showInfoFlag=true;
			var tableTrs=signFrame.getElementsByTagName("tr");
			for(var i=0;i<tableTrs.length;i++){	
				tableTrs[i].className="";
			}
			this.className="clickTr";
		
			var clickTds=this.getElementsByTagName("td");
			showInfoArray=[clickTds[0].innerHTML,clickTds[1].innerHTML,clickTds[2].innerHTML,,clickTds[3].innerHTML,clickTds[4].innerHTML];
			tagSetPostion(clickTds[0].innerHTML,clickTds[1].innerHTML,clickTds[2].innerHTML,"",clickTds[3].innerHTML,clickTds[4].innerHTML, empDep);
			
		}
	}	
}

function bSearchDetailClode(){
	if(getId("searchDetail")){
		getId("mainDiv").removeChild(getId("searchDetail"));
		getId("mainDiv").removeChild(getId("sdClose"));		
	}
	moveFlag=false;
	removeInfo();
}
function tagSetPostion(infoId,infoName,type,infoRmk,tagX,tagY, empDep){	
	// alert(infoId+":"+infoName+":"+type+":"+infoRmk+":"+tagX+":"+tagY);
	var zomcoe= mapCoefficient();	
	var infoX=tagX*zomcoe.a;
	var infoY=tagY*zomcoe.a;
	// 先判断定位的卡片类型：0为人员，1为设备

	// 创建详细信息列表
	if(!getId("showBack")){// 创建总弹出层
		var showBack = document.createElement("div");
		showBack.id = "showBack";
		showBack.style.position = "absolute";
		showBack.style.zIndex="9997";
		showBack.style.width="346px";
		showBack.style.height="200px";	
		showBack.style.left= (infoX-58)+"px";
		showBack.style.top=(infoY-190)+"px";
		showBack.style.background = "url(/SCMDB/images/infoBack.png) no-repeat left top";
		// 创建弹出的主要信息层
		if(!getId("showDetail")){
			var showDiv = document.createElement("div");
			showDiv.id = "showDetail";
			showDiv.style.position = "absolute";
			showDiv.style.zIndex="9998";
			showDiv.style.width="210px";
			showDiv.style.height="200px";	
			showDiv.style.left= (infoX-50)+"px";
			showDiv.style.top=(infoY-190)+"px";
			showDiv.style.background = "url(/SCMDB/images/infoDetail.png) no-repeat left top";
			getId("mapDiv").appendChild(showDiv);
		}
		// 创建关闭按钮
		if(!getId("closeShowImg")){
			var closeShowImg = document.createElement("div");
			closeShowImg.id = "closeShowImg";
			closeShowImg.style.position = "absolute";
			closeShowImg.style.zIndex="9999";
			closeShowImg.style.width="16px";
			closeShowImg.style.height="16px";	
			closeShowImg.style.left= (infoX+124)+"px";
			closeShowImg.style.top=(infoY-180)+"px";
			closeShowImg.style.background = "url(/SCMDB/images/del.gif) no-repeat left top";
			closeShowImg.style.cursor="pointer";
			closeShowImg.onclick=function(){moveFlag=false;removeInfo();}
			getId("mapDiv").appendChild(closeShowImg);
		}
		if(type==0){
			getId("showDetail").innerHTML=getId("showDetail").innerHTML+"<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">卡号</th><td>"+infoId+"</td></tr><tr><th>姓名</th><td>"+infoName+"</td></tr><tr><th>班组</th><td>"+empDep+"</td></tr></table>";
		}else if(type==1){
			getId("showDetail").innerHTML=getId("showDetail").innerHTML+"<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>类型</th><td>设备</td></tr></table>";
		}
		else if(type==10){
			getId("showDetail").innerHTML=getId("showDetail").innerHTML+"<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>状态 </th><td>正常</td></tr></table>";
		}else{
			getId("showDetail").innerHTML=getId("showDetail").innerHTML+"<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>状态 </th><td>损坏</td></tr></table>";
		}
		
		getId("mapDiv").appendChild(showBack);		
		showDiv.onclick=function (){moveFlag=true;}
	}else{
		getId("showBack").style.left= (infoX-58)+"px";
		getId("showBack").style.top=(infoY-190)+"px";
		getId("showDetail").style.left= (infoX-58)+"px";
		getId("showDetail").style.top=(infoY-190)+"px";
		getId("closeShowImg").style.left= (infoX+124)+"px";
		getId("closeShowImg").style.top=(infoY-180)+"px";
		if(type==0){
			getId("showDetail").innerHTML="<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">卡号</th><td>"+infoId+"</td></tr><tr><th>姓名</th><td>"+infoName+"</td></tr><tr><th>班组</th><td>"+empDep+"</td></tr></table>";
		}else if(type==1){
			getId("showDetail").innerHTML="<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>类型</th><td>Equipment</td></tr></table>";
		}
		else if(type==10){
			getId("showDetail").innerHTML="<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>位置</th><td>"+infoRmk+"</td></tr><tr><th>状态</th><td>正常</td></tr></table>";
		}
		else{
			getId("showDetail").innerHTML="<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"showCarTab\"><tr><th width=\"50\">编号</th><td>"+infoId+"</td></tr><tr><th>名称</th><td>"+infoName+"</td></tr><tr><th>位置</th><td>"+infoRmk+"</td></tr><tr><th>状态</th><td>损坏</td></tr></table>";
		}
	}
	var mainDivWidth = parseInt(getId('mainDiv').style.width);
	var mainDivHeight = parseInt(getId('mainDiv').style.height);
	getId("mapDiv").style.left = -parseInt(infoX - mainDivWidth / 2) + "px";
	getId("mapDiv").style.top = -parseInt(infoY - mainDivHeight / 2) + "px";
}

// 删除详细信息
function removeInfo(){	
	if (getId("showDetail")){
		if(!moveFlag){	
			getId("mapDiv").removeChild(getId("showBack"));
			getId("mapDiv").removeChild(getId("closeShowImg"));
			getId("mapDiv").removeChild(getId("showDetail"));
			showInfoFlag=false;
			return false;
		}else{
			moveFlag=false;
		}
	}
}

// 清除定位
function delPosition(){	
	if(getId("showDetail")){
		getId("mapDiv").removeChild(getId("showDetail"));
		getId("mapDiv").removeChild(getId("showBack"));
		getId("mapDiv").removeChild(getId("closeShowImg"));
		
		showInfoFlag=false;
	}
	getId("tagText").value="";
	getId("IDText").value="";
	getId("nameText").value="";
	// 清除查询结果
	if(getId("searchDetail")){
		getId("mapDiv").removeChild(getId("searchDetail"));
		getId("mapDiv").removeChild(getId("sdClose"));
	}
	
	if(getId("searchRealtimeForm_typeWork")){
		var typeWorks=getId("searchRealtimeForm_typeWork").options;
		typeWorks[0].selected = true;
		for (var i=1; i<typeWorks.length; i++)   
		{  
		typeWorks[i].selected = false; 
		}
	}
	if(getId("polyNew")){
		getId("mapDiv").removeChild(getId("polyNew"));
	}
}
function GetXmlHttpObject()
{ 
	if(window.ActiveXObject){
		var waystation=new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		var waystation=new XMLHttpRequest();
		
	}else{var waystation=false;}
	return waystation;
}